package com.xianyun.book.domain.book;

import com.alibaba.cola.exception.BizException;

/**
 * @author ytt
 */
public enum BookStatus {
    /**预售*/
    PRE_SALE(0,"预售"),
    /**在售*/
    IN_SALE(1,"在售"),
    /**促销*/
    PROMOTION(2,"促销"),
    /**无货*/
    SOLD_OUT(3,"无货");
    private Integer statusId;
    private String message;
    public Integer getStatusId() {
        return statusId;
    }

    BookStatus(Integer statusId, String message) {
        this.statusId = statusId;
        this.message = message;
    }

    public void setStatusId(Integer statusId) {
        this.statusId = statusId;
    }
    public static BookStatus getStatusByNumber(int statusInt){
        for (BookStatus bookStatus:values()){
            if (bookStatus.getStatusId() == statusInt){
                return bookStatus;
            }
        }
        throw new BizException("StatusId 错误");
    }

    public String getMessage() {
        return message;
    }
}
